﻿
project(PostProcessing)


add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
############################################################
# Create an executable
############################################################

#输出目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_OUTPUT_BIN_DIR})


#所有.h文件
file(GLOB ALL_HEAD "*.h" "parser/*.h"  "PostCommand/*.h")
#所有.cpp文件
file(GLOB ALL_SOURCE "*.cpp" "parser/*.cpp"  "PostCommand/*.cpp")
#所有.ui文件
file(GLOB ALL_UI "*.ui")

# 定义QCustomPlot DLL导入符号宏定义
ADD_DEFINITIONS("-DQCUSTOMPLOT_USE_LIBRARY")
ADD_DEFINITIONS("-DAPI_PostCommand")

SET(DIR_RESOURCES "${CMAKE_SOURCE_DIR}/Resources")
SET(SRC_QRC_FILES 
    "${DIR_RESOURCES}/post.rc" 
    "${DIR_RESOURCES}/startup.qrc" 
    "${DIR_RESOURCES}/image.qrc"
    "${DIR_RESOURCES}/translations.qrc"
    "${DIR_RESOURCES}/QUI/light/lightstyle.qrc"
)

add_executable(${PROJECT_NAME} 
    ${ALL_HEAD}
    ${ALL_SOURCE}
    ${ALL_UI}
    ${SRC_QRC_FILES}
)

# 仅在 Release 配置下开启 WIN32 子系统
#在 Debug 下它会作为普通的 Console 程序构建；在 Release 下才变成 Win32 GUI 程序。
set_target_properties(${PROJECT_NAME} PROPERTIES
    WIN32_EXECUTABLE "$<$<CONFIG:Release>:ON>"
)

# 包含头文件目录
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} 
    PRIVATE
    ${CMAKE_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/BaseWidget
    ${LIBRARY_VTK_INCLUDE}
    ${LIBRARY_OCC_INCLUDE}
    ${LIBRARY_OPENCV_INCLUDE}
)

# 配置编译选项
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
    SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
    SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
    # 设置release模式不显示控制台
    IF(${PROJECT_RELEASE_TYPE} MATCHES "master")
        SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
    ENDIF()
ENDIF()    


find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets)

TARGET_LINK_DIRECTORIES(${PROJECT_NAME} PRIVATE ${PROJECT_OUTPUT_BIN_DIR})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} BaseModule BaseWidget ScriptManager CommandManager DataManager ProjectManager)
ADD_DEPENDENCIES(${PROJECT_NAME} BaseModule BaseWidget ScriptManager CommandManager DataManager ProjectManager)

#vld路径设置
SET(VLD_DIR ${LIBRARY_THIRDPARTY_DIR}/Libs/windows-x86_64/vld-2.5.1)
FILE(COPY ${VLD_DIR}/bin/vld_x64.dll  DESTINATION ${PROJECT_OUTPUT_BIN_DIR})

INCLUDE_DIRECTORIES(${VLD_DIR}/include ${LIBRARY_QCustomPlot_INCLUDE})

#QCustomPlot组件库
FILE(COPY ${LIBRARY_QCustomPlot_BINS}  DESTINATION ${PROJECT_OUTPUT_BIN_DIR})

MESSAGE(STATUS "Start copying Python Module Script files and Geometry Model and Config Files.")
FILE(COPY ${CMAKE_SOURCE_DIR}/Resources/Fonts DESTINATION ${PROJECT_OUTPUT_BIN_DIR})

target_link_libraries(${PROJECT_NAME} ${VLD_DIR}/lib/vld.lib)
target_link_libraries(${PROJECT_NAME} ${LIBRARY_VTK_LIBS} ${LIBRARY_QCustomPlot_LIBS}  ${LIBRARY_OCC_LIBS}  ${LIBRARY_OPENCV_LIBS})

